﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Sql;
using System.Data.Common;
using System.Data.SqlClient;
namespace sccf
{
    public class SolicitarAgendaModel
    {
        
        static SqlConnection connection = new SqlConnection(Vars.connectionString);
        public static List<string> registrar(string numcons, string indic, DateTime fecha)
        {
            List<string> correoss = new List<string>();
            connection.Open();
            SqlParameter NumCons = new SqlParameter("@NumCons", numcons);
            SqlParameter Indic = new SqlParameter("@Indic", indic);
            SqlParameter Fecha = new SqlParameter("@Fecha", fecha);
            SqlParameter FechaCreac = new SqlParameter("@FechaCreac", DateTime.Today);
            SqlParameter User = new SqlParameter("@User",Vars.Usuario);
            SqlCommand cmd = new SqlCommand("NuevaConvoc", connection);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(NumCons);
            cmd.Parameters.Add(Indic);
            cmd.Parameters.Add(Fecha);
            cmd.Parameters.Add(FechaCreac);
            cmd.Parameters.Add(User);
            try
            {
                SqlDataReader correos = cmd.ExecuteReader();
               
                while (correos.Read())
                {
                    correoss.Add(correos["email"].ToString());
                    correoss.Add(correos["email2"].ToString());
                }
                connection.Close();
                
            }
            catch (SqlException e)
            {
                correoss.Add("error");
                correoss.Add(e.Message);
            }
            return correoss;
            
        }
        public static int consultarconsejocreado()
        {
            connection.Open();
            SqlCommand cmd = new SqlCommand("ConsultarConsejo", connection);
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            SqlDataReader consejos = cmd.ExecuteReader();
            bool consejoactivo = Convert.ToBoolean(consejos.HasRows.ToString());
            connection.Close();
            if (consejoactivo)
            {
                return 1;
            }
            else
                return 0;
           
        }
    }
}